package com.zmn.oms.services.impl.warranty;

import com.zmn.oms.model.entity.warranty.OrderWarrantyProduct;
import com.zmn.oms.model.entity.warranty.WarrantyQuery;
import com.zmn.oms.persistence.interfaces.warranty.OrderWarrantyProductDao;
import com.zmn.oms.services.interfaces.warranty.OrderWarrantyProductService;

import javax.annotation.Resource;
import java.util.Date;
import java.util.List;
import org.springframework.stereotype.Service;

/**
 * 类描述：保单产品
 *
 * @author heciqi
 * @date 2018/11/29 17:03
 */
@Service
public class OrderWarrantyProductServiceImpl implements OrderWarrantyProductService {

	@Resource
	private OrderWarrantyProductDao orderWarrantyProductDao;

	/**
	 * 按订单查询保修卡扩展产品数量
	 * @param orderId
	 * @return
	 */
	@Override
	public int countProExtIdByOrderId(Long orderId) {
		return orderWarrantyProductDao.countProExtIdByWarrId(orderId);
	}

	/**
	 * 按订单id查询
	 *
	 * @param orderId
	 * @return
	 */
	@Override
	public List<OrderWarrantyProduct> listByOrderId(Long orderId) {
		return orderWarrantyProductDao.listByWarrId(orderId);
	}

	/**
	 * 条件查询
	 * @param query
	 * @return
	 */
	@Override
	public List<OrderWarrantyProduct> listByQuery(WarrantyQuery query){
		return orderWarrantyProductDao.listByQuery(query);
	}

	/**
	 * 查询多个订单id 查询
	 * @param orderIdList
	 * @return
	 */
	@Override
	public List<OrderWarrantyProduct> listOrderWarrantyProductByOrderIdList(List<Long> orderIdList) {
		return orderWarrantyProductDao.listOrderWarrantyProductByOrderIdList(orderIdList);
	}

	/**
	 * 新增
	 *
	 * @param orderWarrantyProducts
	 * @return
	 */
	@Override
	public Integer insertAll(List<OrderWarrantyProduct> orderWarrantyProducts) {
		return orderWarrantyProductDao.insertAll(orderWarrantyProducts);
	}

	/**
	 * 修改过期时间
	 * @param orderWarrantyProduct
	 * @return
	 */
	@Override
	public Integer updateExpiredTime(OrderWarrantyProduct orderWarrantyProduct) {
		return orderWarrantyProductDao.updateExpiredTime(orderWarrantyProduct);
	}
	/**
	 * @param orderId
	 * @return
	 */
	@Override
	public Integer deleteByOrderId(Long orderId) {
		return orderWarrantyProductDao.deleteByWarrId(orderId);
	}

    @Override
    public Integer deleteByOrderIdAndProExtId(Long orderId, Long proExtId) {
		return orderWarrantyProductDao.deleteByWarrIdAndProExtId(orderId, proExtId);
    }

	@Override
	public void updateWarrantyMonth(Long orderId, Date completeTime, Integer month) {
		orderWarrantyProductDao.updateWarrantyMonth(orderId, completeTime, month);
	}
}
